package com.bing.bean.Tpp.tuling;

import com.bing.bean.weixin.Article;
import com.bing.bean.weixin.RequestMessage;
import com.bing.bean.weixin.ResponseMessage;
import com.bing.utils.MsgHelper;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2015/6/6.
 */
public class News extends AbstractMsg {

    private List<New> list = new ArrayList<>();

    public List<New> getList() {
        return list;
    }

    public void setList(List<New> list) {
        this.list = list;
    }

    @Override
    public ResponseMessage toMsg(RequestMessage requestMessage) {
        List<Article> articles = new ArrayList<>();
        int i=1;
        for (New n : list) {
            if(i>10){
                break;
            }
            i++;
            Article article = new Article();
            article.setContent(n.getSource());
            article.setDescription(n.getArticle());
            article.setPicUrl(n.getIcon());
            article.setUrl(n.getDetailurl());
            article.setTitle(n.getArticle());
            articles.add(article);
        }

        return MsgHelper.toNews(requestMessage, articles);
    }

    public class New {
        private String article;
        private String source;
        private String detailurl;
        private String icon;

        public String getArticle() {
            return article;
        }

        public void setArticle(String article) {
            this.article = article;
        }

        public String getSource() {
            return source;
        }

        public void setSource(String source) {
            this.source = source;
        }

        public String getDetailurl() {
            return detailurl;
        }

        public void setDetailurl(String detailurl) {
            this.detailurl = detailurl;
        }

        public String getIcon() {
            return icon;
        }

        public void setIcon(String icon) {
            this.icon = icon;
        }
    }
}
